/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package snippet.lab4;

import java.io.*;

/**
 *
 * @author c0806h0581
 */
public class BufferInputStreamDemo {

    /**
     * constructor
     */
    public BufferInputStreamDemo() {


        FileInputStream fileStream = null;
        BufferedInputStream bufferStream = null;

        try {
            //link 1 file into stream
            fileStream = new FileInputStream("D:\123\thu.txt");
            
            //link to buffer stream
            bufferStream = new BufferedInputStream(fileStream);


            //read until end of buffer --> Print buffer
            boolean eofBuffer = false;

            while (!eofBuffer) {
                int intValue = bufferStream.read();
                System.out.print(intValue + " ");

                //check eof
                eofBuffer = (intValue == -1)? true: false;
            }
        } catch (FileNotFoundException ex) {

        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            try {
                fileStream.close();
                bufferStream.close();
            } catch (IOException ex) {
                //Logger.getLogger(BufferInputStreamDemo.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }


    /**
     * 
     * @param arg
     */
    public static void main(String[] arg) {
        new BufferInputStreamDemo();

    }

}
